<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Wxuser extends Model
{
    public $table='wxuser';

    protected $guarded = [];

    public $primaryKey = 'id_wxuser';

    public function userInfo()
    {
        return $this->belongsTo(Userinfo::class,'id_userinfo','id');
    }

    public function creditsRecords()
    {
        return $this->hasMany(CreditsRecod::class,'id_userinfo','id_userinfo');
    }

    public function wxuserMcard()
    {
        return $this->hasOne(WxuserMcard::class,'id_userinfo','id_userinfo');
    }

    public function exchangeRecord()
    {
        return $this->hasMany(CreditsExchangeRecord::class,'id_userinfo','id_userinfo');
    }

    public function giftCardsBuy()
    {
        return $this->hasMany(GiftBuyUsed::class,'buy_user_id','id_userinfo')
            ->where('status','Y');
    }

    public function giftCardBind()
    {
        return $this->hasMany(GiftBuyUsed::class,'use_user_id','id_userinfo');
    }
}
